<?php

namespace App\Jobs\Train;

use App\Trip\Train\Providers\Ctrip\TrainQuery;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class ProcessTicketQuery implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public int    $tries = 5;
    private array $param;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct(array $param)
    {
        $this->param = $param;
    }

    /**
     * Execute the job.
     *
     * @return void
     * @throws GuzzleException
     */
    public function handle()
    {
//        $rand = random_int(0, 9);
//        if ($rand < 8) {
        $query = new TrainQuery();
//        } else {
//            $query = new \App\Trip\Train\Providers\PiaoChi\TrainQuery();
//        }
        $query->queryTicket($this->param);
    }
}
